import BaseLayer from './BaseLayer';
import Color from '../core/Color';
import Circle from '../base/Circle';
import DashLine from '../base/DashLine';
import Point from '../core/Point';


export default class extends BaseLayer {
    constructor(canvas, option) {
        super(canvas);
        this.width = option.width || canvas.width;
        this.height = option.height || canvas.height;
        this.color = new Color(option.color || '#333333');
        this.size = option.size || 10;
        this.point = option.point || new Point(0, 0);
        this.smallCircle = new Circle(this.canvas, this.size);
        this.bigCircle = new Circle(this.canvas, this.size * 3);
        this.smallCircle.setColor(this.color);
        this.bigCircle.setColor(this.color);
        this.bigCircle.alpha = 0.3;
        this.smallCircle.setPosition(this.point.x + this.position.x, this.point.y + this.position.y);
        this.bigCircle.setPosition(this.point.x + this.position.x, this.point.y + this.position.y);
        this.hLine = new DashLine(this.canvas, {
            from: new Point(this.position.x, this.position.y + this.point.y),
            to: new Point(this.position.x + this.width, this.position.y + this.point.y),
            color: new Color('#FFFFFF'),
        });
        this.vLine = new DashLine(this.canvas, {
            from: new Point(this.position.x + this.point.x, this.position.y + this.height),
            to: new Point(this.position.x + this.point.x, this.position.y),
            color: new Color('#FFFFFF')
        });
        this.addChild(this.hLine, this.vLine, this.bigCircle, this.smallCircle);
    }

    setPoint(point) {
        this.point = point;
        this.smallCircle.setPosition(this.point.x + this.position.x, this.point.y + this.position.y);
        this.bigCircle.setPosition(this.point.x + this.position.x, this.point.y + this.position.y);
        this.hLine.setFrom(new Point(this.position.x, this.position.y + this.point.y));
        this.hLine.setTo(new Point(this.position.x + this.width, this.position.y + this.point.y));
        this.vLine.setFrom(new Point(this.position.x + this.point.x, this.position.y + this.height));
        this.vLine.setTo(new Point(this.position.x + this.point.x, this.position.y));

    }
}

